import {TBizcEneryEquipApi} from '@/api/equip/tBizcEneryEquipApi.js'
import moment from "moment";

export const FormEvent = {
  form: {
    id: "",//主键
    taskName: "",//任务名称
    taskNo: "",//任务编码
    maintainUnitNo: '',
    maintainUnitName: '',
    maintainTeamName: '',
    patrolRoomNo: '',
    patrolRoomName: '',
    patrolTargetNames: '',
    patrolTypeNo: '',
    patrolTypeName: '',
    planStartTime: '',
    planEndTime: '',
    patrolDescription: '',
    creator: "",//创建人
    creatTime: "",//创建时间
    remark: '',
    sendPersonName: "",//派单人
    sendTel: "",//派单人电话
    sendTime: "",//派单时间
    xsEndRemark: '',
    patrolTime: ""

  },
  rules: {},
  type: '', ////insert-update//
  initFormData(formData) { 		//初始化表单信�?//
    FormEvent.type = formData.type;
    if (FormEvent.type == 'insert') {
      for (let key in FormEvent.form) {
        FormEvent.form[key] = undefined;
      }
    } else {
      for (let key in FormEvent.form) {
        FormEvent.form[key] = formData.data[key];
      }
      this.FormEvent.form.sendTime = moment().format('YYYY-MM-DD HH:mm:ss')
    }
  },
  saveFormData() {
    if (FormEvent.type == 'insert') {
      //执行新增操作//
      const insertData = [FormEvent.form];
      return TBizcEneryEquipApi.insert(insertData);
    } else {
      //执行更新操作//
      const updateData = [FormEvent.form];
      return TBizcEneryEquipApi.update(updateData);
    }
  },

}


